#{extends 'head.html' /}
#{set title:'蓝莲花 | 捐书' /}


<link rel="stylesheet" href="/public/stylesheets/alert.css" type="text/css" />
<script type="text/javascript" src="/public/javascripts/adu.alert.js"></script>
<script type="text/javascript" src="/public/datepicker/WdatePicker.js"></script>
<!-- content 开始-->
    <div class="cont">
    	<div style="width:500px;margin:0px auto;height:350px;">
	    	<div class="m2_b_c1">
	         	<div class="m2c_a">书名：</div>
	            <div class="m2c_b"><input  id="bookname" type="text"/></div>
	        </div>
	        <div class="m2_b_c1">
	         	<div class="m2c_a">作者：</div>
	            <div class="m2c_b"><input  id="author" type="text"/></div><div style="display:none;" style="margin-top:10px;"><a style="padding-left:10px;" href="/controllers/DonateBooks.moredbook">更多..</a></div>
	        </div>
	        <div class="m2_b_c1">
	         	<div class="m2c_a">捐书方式：</div>
	            <div style="margin-top:6px;"><input onclick="xxc();" value="0"  name="chage" checked="checked" type="radio"/>微微书香上门取书&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input onclick="xxc();" value="1" name="chage" type="radio" />自行邮寄</div>
	        </div>
	       	<div id = "cgone">
	       		<div class="m2_b_c1">
		         	<div class="m2c_a">取书地址：</div>
		            <div class="m2c_b"><input  id="address" type="text"/></div>
		        </div>
		        <div class="m2_b_c1">
		         	<div class="m2c_a">取书时间：</div>
		            <div class="m2c_b"><input onClick="WdatePicker()" id="stime" type="text"/></div><div style="position: relative;"><span style="position: absolute; margin-left:-220px;margin-top:5px;">至</span><div style="margin-left:20px;" class="m2c_b"><input onClick="WdatePicker()"  id="etime" type="text"/></div></div>
		        </div>
		        <div class="m2_b_c1">
		         	<div class="m2c_a">联系电话：</div>
		            <div class="m2c_b"><input  id="telphone" type="text"/></div>
		        </div>
	       	</div>
	       	<div style="display:none;" id = "cgtwo">
	       		<div class="m2_b_c1">
		         	<div class="m2c_a">请将书邮寄至：</div>
		            <div style="margin-top:5px;"><span>0000000000000000000000</span></div>
		        </div>
		        <div class="m2_b_c1">
		         	<div class="m2c_a">邮编：</div>
		            <div style="margin-top:5px;"><span>000000000000000</span></div>
		        </div>
	       	</div>
	        <div class="m2_b_c1">
	         	<div class="m2c_a"></div>
	            <div class=""><input  id="sub" type="button" value="确    定"/></div>
	        </div>
         </div>
         <script type="text/javascript">
         	function xxc(){
         		if($("input[name=chage]:checked").val() == 0){
         			$("#cgone").css("display","");
         			$("#cgtwo").css("display","none");
         		}
         		if($("input[name=chage]:checked").val() == 1){
         			$("#cgone").css("display","none");
         			$("#cgtwo").css("display","");
         		}
         	}
         	
         	$("#sub").click(function(){
         			var bookname = $("#bookname").val();
         			var author = $("#author").val();
					var address = $("#address").val() ;
					
         			$.ajax({
         				type:'post',
         				url :'/controllers/DonateBooks.savedbook',
         				data:({"bookname":$("#bookname").val(),"author":$("#author").val(),"state":$("input[name=chage]:checked").val(),"address":$("#address").val(),"stime":$("#stime").val(),"etime":$("#etime").val(),"telphone":$("#telphone").val()}),
         				dataType:"html",
         				success:function(e){
         					if(e == "1"){
	       						aduConfirmt("感谢您，捐书成功,您需要继续捐书嘛？","提示",function(e){
	       							if(e == true ){
	       								window.location.href = "/controllers/IndexAction.donatebook"
	       							}
	       							if(e == false){
	       								window.location.href = "/index.html"
	       							}
	       						});	
         					}
         					if(e == "0"){
         						aduAlert("捐书失败！","提示");
         					}
         				}
         				
         			});
         	});
         </script>
    </div>